package com.wll.flutter.hybrid;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.android.FlutterActivityLaunchConfigs;
import io.flutter.embedding.android.FlutterView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        EditText paramInput = findViewById(R.id.paramInput);
        findViewById(R.id.jump).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String inputParams = paramInput.getText().toString().trim();
//                FlutterAppActivity.start(MainActivity.this, inputParams);
                MyActivity.start(MainActivity.this, inputParams);

//                flutter官网文档地址： https://flutter.dev/docs/development/add-to-app/android/add-flutter-screen

//                startActivity(
//                        FlutterActivity
//                                .withNewEngine()
//                                .initialRoute("/my_route")
//                                .build(MainActivity.this)
//                );

//                startActivity(
//                        FlutterActivity
//                                .withCachedEngine("my_engine_id")
//                                .build(MainActivity.this)
//                );

//                // Using a new FlutterEngine.
//                startActivity(
//                        FlutterActivity
//                                .withNewEngine()
//                                .backgroundMode(FlutterActivityLaunchConfigs.BackgroundMode.transparent)
//                                .build(MainActivity.this)
//                );

//                // Using a cached FlutterEngine.
//                startActivity(
//                        FlutterActivity
//                                .withCachedEngine("my_engine_id")
//                                .backgroundMode(FlutterActivityLaunchConfigs.BackgroundMode.transparent)
//                                .build(MainActivity.this)
//                );

            }
        });
    }
}
